package com.wechat.back.service.impl;

import com.wechat.back.mapper.NoticeMapper;
import com.wechat.back.pojo.inform.NoticeData;
import com.wechat.back.pojo.inform.NoticeType;
import com.wechat.back.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeMapper noticeMapper;
    @Override
    public List<NoticeData> noticeList() {
        return noticeMapper.noticeList();
    }

    @Override
    public List<NoticeType> typeList() {
        return noticeMapper.typeList();
    }

    @Override
    public void addNotice(NoticeData noticeData) {
        noticeData.setCreateTime(LocalDateTime.now());
        noticeData.setUpdateTime(LocalDateTime.now());
        noticeMapper.addNotice(noticeData);
    }

    @Override
    public void addType(NoticeType noticeType) {
        noticeType.setCreateTime(LocalDateTime.now());
        noticeType.setUpdateTime(LocalDateTime.now());
        noticeMapper.addType(noticeType);
    }

    @Override
    public void deleteNotice(Integer noticeId) {
        noticeMapper.deleteNotice(noticeId);
    }

    @Override
    public void deleteType(Integer typeId) {
        noticeMapper.deleteType(typeId);
    }

    @Override
    public void updateNotice(NoticeData noticeData) {
        noticeData.setUpdateTime(LocalDateTime.now());
        noticeMapper.updateNotice(noticeData);
    }

    @Override
    public void updateType(NoticeType noticeType) {
        noticeType.setUpdateTime(LocalDateTime.now());
        noticeMapper.updateType(noticeType);
    }
}
